package top.lucky.redishmdp.service.impl;

import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import top.lucky.redishmdp.entity.UserInfo;
import top.lucky.redishmdp.mapper.UserInfoMapper;
import top.lucky.redishmdp.service.UserInfoService;

/**
 * @author Jane
 * @date 2022/5/24, 10:40
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {
	
	@Autowired
	private UserInfoMapper userInfoMapper;
	@Override
	@Async("asyncPool")
	public void insert() {
		insertData();
	}
	
	private void insertData() {
		long x = 100000l;
		for (int i = 0; i < 800000; i++) {
			UUID uuid = UUID.fastUUID();
			UserInfo userInfo = new UserInfo();
			userInfo.setUserId(x + i);
			userInfo.setCity("内蒙古");
			userInfo.setIntroduce("哈哈哈哈哈_" + i);
			if (i % 2 == 0) {
				
				userInfo.setGender(true);
			} else {
				userInfo.setGender(false);
			}
			userInfoMapper.insert(userInfo);
		}
	}
}
